package admin.shell.commands;

import java.util.List;

import admin.ui.ProxyMediator;
import core.PluginInfo;

public class ListPluginsCommand extends ShellCommand {

	@Override
	public void execute(ProxyMediator proxy, String[] parameters) {
			
		List<PluginInfo> plugins = proxy.listPlugins();
		
		if (plugins.size() == 0) {
			System.out.println("No plugins deployed");
			return;
		}
			
		System.out.printf("%-20s  %-30s %10s  %-15s\n", "Name", "class", "Running?", "Version");
		
		for (PluginInfo plugin : plugins) {	
			System.out.printf("%-20s  %-30s %10s  %-15d\n", plugin.getName(), plugin.getClassName(), plugin.isRunning() ? "yes" : "no", plugin.getVersion());
		}
		
		System.out.println("\nTotal: " + plugins.size());
	}
}
